//
//  CellForCollect.m
//  ProjectA
//
//  Created by dllo on 16/2/26.
//  Copyright © 2016年 刘旺辉. All rights reserved.
//

#import "CellForCollect.h"
#import <UIImageView+WebCache.h>
#import "ModelForSection1.h"
#import "AppMacro.h"
@interface CellForCollect ()
@property (nonatomic, strong) UIImageView *imageViewForLeft;
@property (nonatomic, strong) UILabel *title;
@property (nonatomic, strong) UILabel *text;
@end

@implementation CellForCollect
- (void)dealloc {
    [_imageViewForLeft release];
    [_title release];
    [_text release];
    [super dealloc];
    
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.imageViewForLeft = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageViewForLeft];
        [_imageViewForLeft release];
        self.imageViewForLeft.layer.cornerRadius = 5;
        self.imageViewForLeft.layer.masksToBounds = YES;
        
        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:self.title];
        [_title release];
        self.title.font = [UIFont systemFontOfSize:15];
        self.title.numberOfLines = 1;
        self.title.textAlignment = 1;
        
        self.title.layer.masksToBounds = YES;
        self.title.layer.borderWidth = 1;
        
        
        
        self.text = [[UILabel alloc] init];
        [self.contentView addSubview:self.text];
        [_text release];
        self.text.font = [UIFont systemFontOfSize:10];
        self.text.numberOfLines = 0;
        self.text.textAlignment = 1;
        self.text.layer.masksToBounds = YES;
        self.text.layer.borderWidth = 1;
        if (ISNIGHT) {
            self.title.layer.borderColor = [[UIColor whiteColor] CGColor];
            self.text.layer.borderColor = [[UIColor whiteColor] CGColor];
        } else {
            self.title.layer.borderColor = [[UIColor blackColor] CGColor];
            self.text.layer.borderColor = [[UIColor blackColor] CGColor];
        }
        
    }
    return self;
}

#define WIDTH self.frame.size.width / 3.f
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.imageViewForLeft.frame = CGRectMake(10, 10, self.frame.size.width / 3.f, self.frame.size.width / 3.f - 20);
    
    self.title.frame = CGRectMake(10 + self.imageViewForLeft.frame.size.width + 10, 10, self.frame.size.width - (10 + self.imageViewForLeft.frame.size.width + 10 + 10), self.imageViewForLeft.frame.size.height / 2);
    self.title.layer.cornerRadius = self.title.frame.size.height / 2.f;
    
    
    self.text.frame = CGRectMake(10 + self.imageViewForLeft.frame.size.width + 10, self.imageViewForLeft.frame.size.height / 2 + 20, self.frame.size.width - (10 + self.imageViewForLeft.frame.size.width + 10 + 10), self.imageViewForLeft.frame.size.height / 2 - 10);
    self.text.layer.cornerRadius = self.text.frame.size.height / 2.f;
    
    self.title.backgroundColor = [UIColor clearColor];
    [UIView setColorWithLabelText:self.title nightColor:L_COLOR_WHITE dayColor:L_COLOR_BLACK];
    self.text.backgroundColor = [UIColor clearColor];
    [UIView setColorWithLabelText:self.text nightColor:L_COLOR_WHITE dayColor:L_COLOR_BLACK];
}
- (void)passData:(ModelForSection1 *)model {
    [self.imageViewForLeft sd_setImageWithURL:[NSURL URLWithString:model.cover_image_s]];
    self.title.text = model.index_title;
    self.text.text = model.text;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
